package com.yc.jpyy.common;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Common {
	
	
	
	//===================   user       ========================================
	
	
	public static final String userYYT = "您未开通预约功能，请联系驾校！";
	
	
	
	
	
	public  static  String   DATABASENAME =  null;

	public static  String rootDir = null;
	
	
	
	
	
	
	
	 public static String timestamp2Date(String str_num) {
	        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	        if (str_num.length() == 13) {
	            String date = sdf.format(new Date(toLong(str_num)));
	            return date;
	        } else {
	            String date = sdf.format(new Date(toInt(str_num) * 1000L));
	            return date;
	        }
	    }
	 /**
	     * String转long
	     *
	     * @param obj
	     * @return 转换异常返回 0
	     */
	    public static long toLong(String obj) {
	        try {
	            return Long.parseLong(obj);
	        } catch (Exception e) {
	        }
	        return 0;
	    }
	    /**
	     * 对象转整
	     *
	     * @param obj
	     * @return 转换异常返回 0
	     */
	    public static int toInt(Object obj) {
	        if (obj == null)
	            return 0;
	        return toInt(obj.toString());
	    }
	    
	
	
	    public static String genMDInfo(String str) throws Exception {
			MessageDigest md;
		     StringBuffer sb = new StringBuffer();
		     try {
		          md = MessageDigest.getInstance("MD5");
		          md.update(str.getBytes());
		          byte[] data = md.digest();
		          int index;
		          for(byte b : data) {
		               index = b;
		               if(index < 0) index += 256;
		               if(index < 16) sb.append("0");
		               sb.append(Integer.toHexString(index));
		          }
		     } catch (NoSuchAlgorithmException e) {
		      e.printStackTrace();
		     }
		     return sb.toString().toUpperCase();
		}
	
	
	
	//===================   course       ========================================
	
	
	public static final String courserEvaS = "课程评价成功！";
	
	public static final String courserEvaF = "课程评价失败！";
	
	public static final String courserEvaT = "课程暂时无法评价！";	
	
	public static final String courserEvaH = "您还有未评价的课程，无法预约！";	
	
	public static final String courserCancleS = "课程取消预约成功！";
	
	public static final String courserCancleF = "课程取消预约失败，请刷新后重试！";
	
	public static final String courserTodayCancleF = "课程已过取消时间，请联系驾校管理员！";
	
	public static final String courserFailure = "该课程无法预约，请刷新后重试！";
	
	public static final String yySuccess = "预约成功！";
	
	public static final String yyFailure = "预约失败， 请刷新后重试！";
	
	public static final String yyStudentFull = "该课程预约数量已满！";
	
	public static final String yyTimeF = "您的学时不够，无法预约，请及时充值或联系管理员！";
	
	public static final String yyBeforeTimeF = "此课程已超出提前预约时间！";
	
	
	
	

}
